package com.wangfa.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wangfa.entity.Goods;
import com.wangfa.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wangfa
 * @since 2020-12-17
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    IGoodsService goodsService;

    @RequestMapping("list")
    public Page<Goods>getlist(@RequestBody Goods goods, @RequestParam(defaultValue = "1") int current, @RequestParam(defaultValue = "2") int size, HttpServletRequest request){
        Page<Goods> page = new Page<>(current,size);
        Page<Goods> pageInfo = goodsService.selectPageVo(goods, page);
        request.setAttribute("pageInfo",pageInfo);
        List<Goods> list = goodsService.list();
        return pageInfo;
    }

    @RequestMapping("list2")
    public List<Goods>getGoods(){
        List<Goods> list = goodsService.list();
        return list;
    }



}

